#ifndef MORPHOCARD_H
#define MORPHOCARD_H

#include "iopcsclite.h"

#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

class MorphoCard
{
    vector<string> readers;

public:
    MorphoCard();
    ~MorphoCard();
    string  leerSmartCard(int r = 0);
    ///     write at register one & two
    bool    setData(string data, int r = 0, int rg = 1);
    bool    setValor(char valor, int r = 0);
    bool    clean();
    bool    cardInserted(int r = 0);
    bool    connectCardToSelectedReader(string reader);
    ///     list the readers founded before the execution of app, not after
    vector<string> getReaders();
private:
    ///     search the list of readers plugged to PC before the execution of app, not after
    bool    searchReaders();
    bool    getResponseApdu(string &sHeader);
    bool    selectAppId();
    size_t  lengthData(int regNum);
    void    genWriteApdu(int regNum, unsigned char *apdu);
    void    genReadApdu(int regNum, unsigned char *apdu);
    ///     always genWriteApdu or genReadApdu is called first
    void    genResponseApdu(unsigned char *apdu);
};

#endif // MORPHOCARD_H
